package com.common.core.utils;


import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * Created by Austin on 16/1/31.
 */
public class Sign {

    public static String toignShort(String[] args) {
        String secretkey = "UJMpkYFiq4YDMLkEXgqYUltbfWCb7p67";// 32位密钥
        List<String> paramList = new ArrayList<String>();
        for (int i = 0; i < args.length; i++) {
            String val = args[i];
            if(val.endsWith("null")) continue;
            paramList.add(args[i]);

        }
        Collections.sort(paramList);
        StringBuilder builder = new StringBuilder();
        for (String param : paramList) {
            builder.append(param);
        }
        builder.append(secretkey);
        String sign = MD5Tool.toMd5(builder.toString());
        return sign;
    }



    /**
     * 获取加密
     * 不用传递公共的uid等信息
     *
     * @return
     * @param paramList
     */
    public static String toSignShort(List<String> paramList) {
        String secretkey = "UJMpkYFiq4YDMLkEXgqYUltbfWCb7p67";// 32位密钥
        Collections.sort(paramList);
        StringBuilder builder = new StringBuilder();
        for (String param : paramList) {
            if(param.endsWith("null")) continue;
            builder.append(param);
        }
        builder.append(secretkey);
        String sign = MD5Tool.toMd5(builder.toString());
        return sign;

    }



}
